package com.xiaomengkuan.test.util;


import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author Faraj Mujey
 * -- Creation Time: 2021-01-09 8:34 下午, File Encoding: utf8 --
 */
public class YsjUtil {
    public static String getTimeStr(Date date){
        long nowTimestamp = new Date().getTime();
        long tempTimestamp = date.getTime();
        long difference = nowTimestamp - tempTimestamp;
        if (difference < 60000){
            return "刚刚";
        } else if(difference < 120000) {
            return "两分钟前";
        } else if (difference < 180000) {
            return "三分钟前";
        } else if (difference < 240000) {
            return "四分钟前";
        } else if (difference < 300000) {
            return "五分钟前";
        } else if (difference < 600000){
            return "十分钟前";
        } else if (difference < 900000){
            return "十五分钟前";
        } else if(difference < 1800000){
            return "半小时前";
        } else if(difference < 2400000){
            return "四十分钟前";
        } else if (difference < 3000000){
            return "五十分钟前";
        } else if(difference < 3600000) {
            return "一小时前";
        } else if(difference < 7200000) {
            return "两小时前";
        } else if(difference < 10800000) {
            return "三小时前";
        } else {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM" +
                    "月dd日 HH:mm");
            return simpleDateFormat.format(date);
        }
    }
}
